<template>
  <div>
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' @condition-changed='search'>
        <form class="form-inline" partial>
          <div class="form-group">
            <label for="c_plan_year">年份：</label>
            <v-select id="f_plan_year" :value.sync="$parent.$parent.model.f_plan_year"
            :options='$parent.$parent.c_year_list' close-on-select clear-button></v-select>
            <!-- <button type="button" class="btn btn-success width-80" @click="search()">查询</button> -->
          </div>
          <div class="form-group">
            安检员:
            <chooser :userid.sync='$parent.$parent.loginer.id' resource-type="user" :width='300' :select-data.sync='$parent.$parent.model.chosenOrg'></chooser>
          </div>
          <div class="form-group">
              <button type="button" class="btn btn-success width-80" @click="search()">查询</button>
          </div>
          <div>
            {{$parent.$parent.model.chosenOrg.fullname}}
          </div>
        <!-- <div class="form-group">
          <v-select id="f_subcompany"
            placeholder='安检员'
            :value.sync="$parent.$parent.model.chosenOrg"
            :options='$parent.$parent.user_type'
            v-on:keyup.enter="search"
            close-on-select clear-button>
          </v-select>
        </div> -->

        </form>
      </criteria>
      <data-grid :model="model" partial='list' v-ref:grid>
        <template partial='head'>
          <tr>
            <th>年份</th>
            <th>月份</th>
            <th>安检员</th>
            <th>计划数</th>
          </tr>
        </template>
        <template partial='body'>
          <td>{{row.f_plan_year}}</td>
          <td>{{row.f_plan_month}}</td>
          <td>{{row.f_checker}}</td>
          <td>{{row.c}}</td>
        </template>
        <template partial="foot">
          <span>计划项总数：{{ model.sums.c }}</span>
        </template>
      </data-grid>
    </criteria-paged>
    </div>
</template>
<script>
import { PagedList } from 'vue-client'
import Vue from 'vue'
// import AppData from '../../stores/AppData'
import * as Util from '../Util'
export default {
  title: '安检计划查询',
  data () {
    let options = []
    let year = (new Date()).getFullYear()
    for(let i = year - 8; i <= year +1; i++ )
      options.push({label: i+ '', value: i+ ''})
    let model = new PagedList('rs/sql/planCount', 20,
    {f_plan_year: 'this.f_plan_year[0]', f_checker: 'this.chosenOrg.name', f_subcompany: 'this.f_subcompany'}, {c: ''})
    model.f_plan_year = year + ''
    model.chosenOrg = {id: 0}
    return {
      model: model,
      c_year_list: options,
      loginer: Util.f
    }
  },
  ready () {
    this.model.id = this.$parent.loginer.id
    this.model.chosenOrg.name = ''
    this.model.f_subcompany = Vue.f_subcompany
  },
  computed: {
    selected () {
      return this.$refs.paged.$refs.grid.selected
    }
  }
}
</script>
